import { AddressItem } from '@/api/address';
import { defineStore } from 'pinia';
import { ref } from 'vue';

export const useAddressStore = defineStore(
  'address',
  () => {
    const address = ref({} as AddressItem);
    const setAddress = (newAddress: AddressItem) => {
      address.value = newAddress;
    };
    return { address, setAddress };
  },
  {
    persist: {
      storage: {
        getItem(key) {
          return uni.getStorageSync(key);
        },
        setItem(key, value) {
          uni.setStorageSync(key, value);
        },
      },
    },
  }
);
